//package com.cmdi.feign;
//
//import feign.Logger;
//import feign.RequestInterceptor;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.http.HttpHeaders;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
///**
// * @Description: FeignConfig
// * @Author: gaozb
// * 因为异步调用得到的ServletRequestAttributes attributes为null
// */
//@Component
//public class FeignConfig {
//    @Bean
//    public RequestInterceptor requestInterceptor() {
//        return requestTemplate -> {
//            ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
//            System.out.println("attributes = " + attributes);
//            if(null != attributes) {
//                javax.servlet.http.HttpServletRequest request = attributes.getRequest();
//
//                System.out.println("Feign request: " + request.getRequestURI());
//                System.out.println(request.getHeader(HttpHeaders.AUTHORIZATION));
//                requestTemplate.header(HttpHeaders.AUTHORIZATION, request.getHeader(HttpHeaders.AUTHORIZATION));
//            }
//        };
//    }
//
//    @Bean
//    Logger.Level feignLoggerLevel() {
//        return Logger.Level.FULL;
//    }
//}